import java.util.Scanner;

//打印正方形，用户输入正方形边长，用*打印出空心正方形。
public class 第四题1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入正方形的边长： ");
        int a = scanner.nextInt();
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < a; j++) {
                if (i == 0) {
                    System.out.print("*");
                } else if (i == a - 1) {
                    System.out.print("*");
                } else if (i == a-1 || j ==0) {
                    System.out.print("*");
                }else if (i == 0 || j == a - 1) {
                    System.out.print("*");
                }else {
                        System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}
